package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.IotProductModule;
import com.econ.powercloud.ems.dal.mapper.IotProductModuleMapper;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author jwc
 * @since 2022/10/19
 */
@Repository
public class IotProductModuleDAO extends ServiceImpl<IotProductModuleMapper, IotProductModule> {

    public List<IotProductModule> selectByProductKeys(List<String> productKeys){
        LambdaQueryWrapper<IotProductModule> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.in(!CollectionUtils.isEmpty(productKeys),IotProductModule::getProductKey,productKeys);
        return this.getBaseMapper().selectList(lambdaQueryWrapper);
    }

    public IotProductModule selectByProductKeyAndModuleCode(String productKey,String moduleCode){
        return this.getOne(Wrappers.<IotProductModule>lambdaQuery().eq(IotProductModule::getProductKey, productKey).eq(IotProductModule::getModuleCode, moduleCode));
    }

}
